<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>打印配货单</title>
    <script src="/jquery-1.8.3.min.js"></script>
    <script src="/printThis.js"></script>
    <script src="/chineseMoney.js"></script>
    <link rel="stylesheet" href="/print.css"/>
</head>
<body>
<div id="receiptPrintArea0">
    <h3 style="text-align: center">配货单-<span class="router"></span></h3>
    <br/>
    <table width="100%">
        <tr>
            <td width="25%">配货日期范围：</td><td width="75%"><span class="distributionDate"></span></td>
        </tr>
        <tr>
            <td width="25%">餐别：</td><td width="75%"><span class="mealsType"></span></td>
        </tr>
    </table>
    <br/>
    <table style="width: 100%;" class="printTable">
        <thead>
        <tr>
            <td width="5%">序号</td>
            <td width="10%">配货日期</td>
            <td width="20%">订单号</td>
            <td width="30%">客户</td>
            <td width="20%">餐别</td>
            <td width="10%">份数</td>
        </tr>
        </thead>
        <tbody class="content">
        </tbody>
    </table>
</div>
<script th:inline="javascript">
    var params = [[${params}]];
    var router = params.router;
    var routerName = params.routerName;
    var beginDistributionDate = params.beginDistributionDate;
    var endDistributionDate = params.endDistributionDate;
    var mealsTypeId = params.mealsTypeId;
    var mealsTypeName = params.mealsTypeName;
    var backAddress = params.backAddress;
    function print() {
        $("#receiptPrintArea0").printThis({
            debug: false,
            importCSS: true,
            importStyle: true,
            printContainer: true,
            pageTitle: "",
            removeInline: false,
            printDelay: 333,
            header: null,
            formValues: true
        });
    }
    $.ajax({
            url: backAddress + "/api/order/querySupplySummaryByRouter",
            data : JSON.stringify({
                "beginDistributionDate" : beginDistributionDate,
                "endDistributionDate" : endDistributionDate,
                "router" : router,
                "mealsTypeId" : mealsTypeId,
                "recipe" : true
            }),
            type: "post",
            contentType: "application/json;charset=utf-8",
            dataType: "json",
            //traditional : true,
            success: function (data) {
                $(".distributionDate")[0].innerText = beginDistributionDate + '至' + endDistributionDate;
                $(".mealsType")[0].innerText = mealsTypeName;
                $(".router")[0].innerText = routerName;
                var str = '' ;
                for (var i = 0 ; i < data.data.data.length ; i++) {
                    str += "<tr><td width=\"5%\">" + (i + 1) + "</td>" +
                        "<td width=\"15%\">" + data.data.data[i].distributionDate + "</td>" +
                        "<td width=\"20%\">" + data.data.data[i].ordersId + "</td>" +
                        "<td width=\"30%\">" + data.data.data[i].customerName + "</td>" +
                        "<td width=\"20%\">" + data.data.data[i].mealsTypeName + "</td>" +
                        "<td width=\"10%\">" + data.data.data[i].totalAmount + "</td></tr>" ;
                }
                $(".content")[0].innerHTML = str;
                print()
            },
            error: function (status) {
                alert(status)
            }
        }
    )
</script>

</body>
</html>